#!/bin/bash

HOST=registry.cn-beijing.aliyuncs.com/duo_dian/yapi
read -p "输入最新版本「EG:1.9.2」：" version
PREFIX=${HOST}:${version}

echo "将下载版本:$version"
echo -e "\033[32m 下载包 (version $1) \033[0m"

wget -O yapi.tgz http://registry.npm.taobao.org/yapi-vendor/download/yapi-vendor-$version.tgz

 if [ $? -ne 0 ]; then
    echo -e "\033[31m wget下载yapi失败，确保 wget -O yapi.tgz http://registry.npm.taobao.org/yapi-vendor/download/yapi-vendor-$version.tgz 可以正常运行 \033[0m"
    exit ;
 fi

echo -e "\033[32m 创建 docker 镜像,输入本机登录密码获取权限 \033[0m"

sudo docker build -t ${PREFIX}:${tag} .
echo "构建成功."
echo "上传命令... docker push "${PREFIX}
docker push ${PREFIX}
echo "上传完成"
